home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Languguage OS 2
/
Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO
/
gnu
/
nihcl-30.lha
/
nihcl-3.0
/
lib
/
_main.c_p
< prev
next >
Wrap
Text File
|
1990-05-23
|
2KB
|
87 lines
/* _main.c -- "patch" version with NIH Class Library initialization
THIS SOFTWARE FITS THE DESCRIPTION IN THE U.S. COPYRIGHT ACT OF A
"UNITED STATES GOVERNMENT WORK". IT WAS WRITTEN AS A PART OF THE
AUTHOR'S OFFICIAL DUTIES AS A GOVERNMENT EMPLOYEE. THIS MEANS IT
CANNOT BE COPYRIGHTED. THIS SOFTWARE IS FREELY AVAILABLE TO THE
PUBLIC FOR USE WITHOUT A COPYRIGHT NOTICE, AND THERE ARE NO
RESTRICTIONS ON ITS USE, NOW OR SUBSEQUENTLY.
Author:
Ted Persky
Bg. 12A, Rm. 2031
Computer Systems Laboratory
Division of Computer Research and Technology
National Institutes of Health
Bethesda, Maryland 20892
Phone: (301) 496-2963
uucp: uunet!nih-csl!ted
December, 1988
Function:
_main is called at execution time before the programmer's
"main" program. It runs through the __linkl linked list
of constructors and calls them all to initialize static and
external objects. It finally calls the NIH Class Library
initialization routine.
Modification History:
$Log: _main.c_p,v $
Revision 3.0 90/05/23 11:01:46 kgorlen
Release for 1st edition.
*/
#include "Object.h"
static char RCSID[] = "$Header: /afs/alw.nih.gov/unix/sun4_40c/usr/local/src/nihcl-3.0/share/lib/RCS/_main.c_p,v 3.0 90/05/23 11:01:46 kgorlen Rel $";
typedef int (*PFI) ();
struct staticCtorDtorLink {
struct staticCtorDtorLink* next; //next link in the chain
PFI ctor; //ptr to ctor function
PFI dtor; //ptr to dtor function
};
#ifdef __cplusplus
extern "C" { extern void _main(); };
struct staticCtorDtorLink* __head;
#else
struct staticCtorDtorLink* __HEAD;
#endif
extern void _main()
{
#ifdef __cplusplus
struct staticCtorDtorLink* current = __head;
struct staticCtorDtorLink* previous = 0;
#else
struct staticCtorDtorLink* current = __HEAD;
#endif
while (current != (staticCtorDtorLink*)0) {
if (current->ctor != (PFI) 0) (*(current->ctor))();
#ifdef __cplusplus
struct staticCtorDtorLink* next = current->next;
current->next = previous;
previous = current;
current = next;
#else
current = current->next
#endif
}
#ifdef __cplusplus
__head = previous;
#endif
NIHCL::initialize();
}